package com.maben.udp.V1.client;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.ip.udp.UnicastSendingMessageHandler;

/**
 * udp 配置
 */
@Configuration
public class UdpIntegrationClientConfig {

    @Value("${udp.port:9999}")
    private Integer udpPort;

    @Value("${udp.ip:127.0.0.1}")
    private String udpIp;

    @Bean
    @ServiceActivator(inputChannel = "udpOut")
    public UnicastSendingMessageHandler unicastSendingMessageHandler() {
        return new UnicastSendingMessageHandler(udpIp, udpPort);
    }

}